/*   1:    */ package com.atomikos.icatch.imp;
/*   2:    */ 
/*   3:    */ import com.atomikos.diagnostics.Console;
/*   4:    */ import com.atomikos.icatch.HeurCommitException;
/*   5:    */ import com.atomikos.icatch.HeurHazardException;
/*   6:    */ import com.atomikos.icatch.HeurMixedException;
/*   7:    */ import com.atomikos.icatch.HeurRollbackException;
/*   8:    */ import com.atomikos.icatch.HeuristicMessage;
/*   9:    */ import com.atomikos.icatch.Participant;
/*  10:    */ import com.atomikos.icatch.RollbackException;
/*  11:    */ import com.atomikos.icatch.SysException;
/*  12:    */ import com.atomikos.icatch.TxState;
/*  13:    */ import com.atomikos.icatch.imp.thread.InterruptedExceptionHelper;
/*  14:    */ import com.atomikos.icatch.system.Configuration;
/*  15:    */ import java.io.IOException;
/*  16:    */ import java.io.Serializable;
/*  17:    */ import java.util.Collection;
/*  18:    */ import java.util.Dictionary;
/*  19:    */ import java.util.Enumeration;
/*  20:    */ import java.util.Hashtable;
/*  21:    */ import java.util.Iterator;
/*  22:    */ import java.util.Stack;
/*  23:    */ import java.util.Vector;
/*  24:    */ 
/*  25:    */ abstract class CoordinatorStateHandler
/*  26:    */   implements Serializable, Cloneable
/*  27:    */ {
/*  28:    */   private static final int THREADS = 1;
/*  29:    */   private transient CoordinatorImp coordinator_;
/*  30:    */   private Hashtable readOnlyTable_;
/*  31:    */   private transient Propagator propagator_;
/*  32:    */   private transient Stack replayStack_;
/*  33:    */   private Boolean committed_;
/*  34:    */   private transient Dictionary cascadeList_;
/*  35:    */   private Hashtable heuristicMap_;
/*  36:    */   
/*  37:    */   protected CoordinatorStateHandler(CoordinatorImp coordinator)
/*  38:    */   {
/*  39:101 */     this.coordinator_ = coordinator;
/*  40:102 */     this.replayStack_ = new Stack();
/*  41:103 */     this.readOnlyTable_ = new Hashtable();
/*  42:104 */     this.committed_ = null;
/*  43:    */     
/*  44:106 */     this.heuristicMap_ = new Hashtable();
/*  45:107 */     this.heuristicMap_.put(TxState.HEUR_HAZARD, new Stack());
/*  46:108 */     this.heuristicMap_.put(TxState.HEUR_MIXED, new Stack());
/*  47:109 */     this.heuristicMap_.put(TxState.HEUR_ABORTED, new Stack());
/*  48:110 */     this.heuristicMap_.put(TxState.HEUR_COMMITTED, new Stack());
/*  49:111 */     this.heuristicMap_.put(TxState.TERMINATED, new Stack());
/*  50:    */   }
/*  51:    */   
/*  52:    */   protected CoordinatorStateHandler(CoordinatorStateHandler other)
/*  53:    */   {
/*  54:125 */     this.coordinator_ = other.coordinator_;
/*  55:126 */     this.propagator_ = other.propagator_;
/*  56:127 */     this.replayStack_ = other.replayStack_;
/*  57:128 */     this.readOnlyTable_ = other.readOnlyTable_;
/*  58:129 */     this.committed_ = other.committed_;
/*  59:130 */     this.cascadeList_ = other.cascadeList_;
/*  60:    */     
/*  61:132 */     this.heuristicMap_ = other.heuristicMap_;
/*  62:    */   }
/*  63:    */   
/*  64:    */   void setCommitted()
/*  65:    */   {
/*  66:142 */     this.committed_ = new Boolean(true);
/*  67:    */   }
/*  68:    */   
/*  69:    */   public Object clone()
/*  70:    */   {
/*  71:155 */     CoordinatorStateHandler clone = null;
/*  72:    */     try
/*  73:    */     {
/*  74:157 */       clone = (CoordinatorStateHandler)super.clone();
/*  75:158 */       clone.readOnlyTable_ = ((Hashtable)this.readOnlyTable_.clone());
/*  76:    */       
/*  77:160 */       clone.heuristicMap_ = new Hashtable();
/*  78:    */       
/*  79:162 */       Stack hazStack = (Stack)this.heuristicMap_.get(TxState.HEUR_HAZARD);
/*  80:163 */       Stack mixStack = (Stack)this.heuristicMap_.get(TxState.HEUR_MIXED);
/*  81:164 */       Stack comStack = (Stack)this.heuristicMap_.get(TxState.HEUR_COMMITTED);
/*  82:    */       
/*  83:166 */       Stack abStack = (Stack)this.heuristicMap_.get(TxState.HEUR_ABORTED);
/*  84:167 */       Stack termStack = (Stack)this.heuristicMap_.get(TxState.TERMINATED);
/*  85:    */       
/*  86:169 */       clone.heuristicMap_.put(TxState.HEUR_HAZARD, hazStack.clone());
/*  87:170 */       clone.heuristicMap_.put(TxState.HEUR_MIXED, mixStack.clone());
/*  88:171 */       clone.heuristicMap_.put(TxState.HEUR_COMMITTED, comStack.clone());
/*  89:    */       
/*  90:173 */       clone.heuristicMap_.put(TxState.HEUR_ABORTED, abStack.clone());
/*  91:174 */       clone.heuristicMap_.put(TxState.TERMINATED, termStack.clone());
/*  92:    */     }
/*  93:    */     catch (CloneNotSupportedException e)
/*  94:    */     {
/*  95:176 */       throw new RuntimeException("CoordinatorStateHandler: clone failure :" + e.getMessage());
/*  96:    */     }
/*  97:181 */     return clone;
/*  98:    */   }
/*  99:    */   
/* 100:    */   protected void addToHeuristicMap(Participant p, Object state)
/* 101:    */   {
/* 102:196 */     Stack stack = (Stack)this.heuristicMap_.get(state);
/* 103:    */     
/* 104:    */ 
/* 105:199 */     stack.push(p);
/* 106:    */   }
/* 107:    */   
/* 108:    */   protected void addToHeuristicMap(Hashtable participants)
/* 109:    */   {
/* 110:215 */     Enumeration parts = participants.keys();
/* 111:216 */     while (parts.hasMoreElements())
/* 112:    */     {
/* 113:217 */       Participant next = (Participant)parts.nextElement();
/* 114:218 */       Object state = participants.get(next);
/* 115:219 */       addToHeuristicMap(next, state);
/* 116:    */     }
/* 117:    */   }
/* 118:    */   
/* 119:    */   protected HeuristicMessage[] getHeuristicMessages(Object heuristicState)
/* 120:    */   {
/* 121:237 */     Vector msgs = new Vector();
/* 122:    */     
/* 123:239 */     Stack parts = (Stack)this.heuristicMap_.get(heuristicState);
/* 124:240 */     if (parts == null) {
/* 125:241 */       throw new RuntimeException("Error: getHeuristicMessages for non-mapped heuristic state: " + heuristicState);
/* 126:    */     }
/* 127:244 */     Enumeration enumm = parts.elements();
/* 128:245 */     while (enumm.hasMoreElements())
/* 129:    */     {
/* 130:246 */       Participant p = (Participant)enumm.nextElement();
/* 131:247 */       HeuristicMessage[] errs = p.getHeuristicMessages();
/* 132:248 */       if (errs != null) {
/* 133:249 */         for (int i = 0; i < errs.length; i++) {
/* 134:250 */           msgs.addElement(errs[i]);
/* 135:    */         }
/* 136:    */       }
/* 137:    */     }
/* 138:254 */     HeuristicMessage[] template = new HeuristicMessage[0];
/* 139:255 */     return (HeuristicMessage[])msgs.toArray(template);
/* 140:    */   }
/* 141:    */   
/* 142:    */   protected HeuristicMessage[] getHeuristicMessages()
/* 143:    */   {
/* 144:269 */     Vector msgs = new Vector();
/* 145:270 */     Enumeration enumm = this.coordinator_.getParticipants().elements();
/* 146:271 */     while (enumm.hasMoreElements())
/* 147:    */     {
/* 148:272 */       Participant p = (Participant)enumm.nextElement();
/* 149:273 */       HeuristicMessage[] errs = p.getHeuristicMessages();
/* 150:274 */       if (errs != null) {
/* 151:275 */         for (int i = 0; i < errs.length; i++) {
/* 152:276 */           msgs.addElement(errs[i]);
/* 153:    */         }
/* 154:    */       }
/* 155:    */     }
/* 156:281 */     HeuristicMessage[] template = new HeuristicMessage[0];
/* 157:282 */     return (HeuristicMessage[])msgs.toArray(template);
/* 158:    */   }
/* 159:    */   
/* 160:    */   protected CoordinatorImp getCoordinator()
/* 161:    */   {
/* 162:293 */     return this.coordinator_;
/* 163:    */   }
/* 164:    */   
/* 165:    */   protected long getRollbackTicks()
/* 166:    */   {
/* 167:299 */     return 0L;
/* 168:    */   }
/* 169:    */   
/* 170:    */   protected Stack getReplayStack()
/* 171:    */   {
/* 172:311 */     return this.replayStack_;
/* 173:    */   }
/* 174:    */   
/* 175:    */   protected Hashtable getReadOnlyTable()
/* 176:    */   {
/* 177:322 */     return this.readOnlyTable_;
/* 178:    */   }
/* 179:    */   
/* 180:    */   protected Dictionary getCascadeList()
/* 181:    */   {
/* 182:333 */     return this.cascadeList_;
/* 183:    */   }
/* 184:    */   
/* 185:    */   protected Propagator getPropagator()
/* 186:    */   {
/* 187:344 */     return this.propagator_;
/* 188:    */   }
/* 189:    */   
/* 190:    */   protected Boolean getCommitted()
/* 191:    */   {
/* 192:355 */     return this.committed_;
/* 193:    */   }
/* 194:    */   
/* 195:    */   protected boolean isCommitted()
/* 196:    */   {
/* 197:366 */     if (this.committed_ == null) {
/* 198:367 */       return false;
/* 199:    */     }
/* 200:369 */     return this.committed_.booleanValue();
/* 201:    */   }
/* 202:    */   
/* 203:    */   protected void printMsg(String message)
/* 204:    */   {
/* 205:    */     try
/* 206:    */     {
/* 207:382 */       Console console = this.coordinator_.getConsole();
/* 208:383 */       if (console != null) {
/* 209:384 */         console.println(message);
/* 210:    */       }
/* 211:    */     }
/* 212:    */     catch (IOException io) {}
/* 213:    */   }
/* 214:    */   
/* 215:    */   protected void printMsg(String msg, int level)
/* 216:    */   {
/* 217:391 */     Console console = this.coordinator_.getConsole();
/* 218:392 */     if (console != null) {
/* 219:    */       try
/* 220:    */       {
/* 221:394 */         console.println(msg, level);
/* 222:    */       }
/* 223:    */       catch (IOException ioerr) {}
/* 224:    */     }
/* 225:    */   }
/* 226:    */   
/* 227:    */   protected void setReadOnlyTable(Hashtable table)
/* 228:    */   {
/* 229:410 */     this.readOnlyTable_ = table;
/* 230:    */   }
/* 231:    */   
/* 232:    */   protected void activate()
/* 233:    */   {
/* 234:424 */     boolean threaded = !this.coordinator_.prefersSingleThreaded2PC();
/* 235:425 */     if (this.propagator_ == null) {
/* 236:426 */       this.propagator_ = new Propagator(threaded);
/* 237:    */     }
/* 238:    */   }
/* 239:    */   
/* 240:    */   protected void recover(CoordinatorImp coordinator)
/* 241:    */   {
/* 242:439 */     this.coordinator_ = coordinator;
/* 243:440 */     this.replayStack_ = new Stack();
/* 244:    */   }
/* 245:    */   
/* 246:    */   protected void dispose()
/* 247:    */   {
/* 248:451 */     this.propagator_ = null;
/* 249:    */   }
/* 250:    */   
/* 251:    */   protected Boolean replayCompletion(Participant participant)
/* 252:    */     throws IllegalStateException
/* 253:    */   {
/* 254:467 */     if (!this.replayStack_.contains(participant)) {
/* 255:468 */       this.replayStack_.push(participant);
/* 256:    */     }
/* 257:470 */     return this.committed_;
/* 258:    */   }
/* 259:    */   
/* 260:    */   protected void addAllForReplay(Collection participants)
/* 261:    */   {
/* 262:480 */     Iterator it = participants.iterator();
/* 263:481 */     while (it.hasNext())
/* 264:    */     {
/* 265:482 */       Participant p = (Participant)it.next();
/* 266:483 */       replayCompletion(p);
/* 267:    */     }
/* 268:    */   }
/* 269:    */   
/* 270:    */   protected void setCascadeList(Dictionary allParticipants)
/* 271:    */   {
/* 272:493 */     this.cascadeList_ = allParticipants;
/* 273:    */   }
/* 274:    */   
/* 275:    */   protected abstract void onTimeout();
/* 276:    */   
/* 277:    */   abstract Object getState();
/* 278:    */   
/* 279:    */   abstract void setGlobalSiblingCount(int paramInt);
/* 280:    */   
/* 281:    */   protected abstract int prepare()
/* 282:    */     throws RollbackException, IllegalStateException, HeurHazardException, HeurMixedException, SysException;
/* 283:    */   
/* 284:    */   protected abstract HeuristicMessage[] commit(boolean paramBoolean)
/* 285:    */     throws HeurRollbackException, HeurMixedException, HeurHazardException, IllegalStateException, RollbackException, SysException;
/* 286:    */   
/* 287:    */   protected abstract HeuristicMessage[] rollback()
/* 288:    */     throws HeurCommitException, HeurMixedException, SysException, HeurHazardException, IllegalStateException;
/* 289:    */   
/* 290:    */   protected HeuristicMessage[] commit(boolean heuristic, boolean onePhase)
/* 291:    */     throws HeurRollbackException, HeurMixedException, HeurHazardException, IllegalStateException, RollbackException, SysException
/* 292:    */   {
/* 293:565 */     Stack errors = new Stack();
/* 294:566 */     CoordinatorStateHandler nextStateHandler = null;
/* 295:    */     try
/* 296:    */     {
/* 297:570 */       Vector participants = this.coordinator_.getParticipants();
/* 298:571 */       int count = participants.size() - this.readOnlyTable_.size();
/* 299:572 */       TerminationResult commitresult = new TerminationResult(count);
/* 300:    */       
/* 301:    */ 
/* 302:575 */       this.committed_ = new Boolean(true);
/* 303:    */       try
/* 304:    */       {
/* 305:580 */         this.coordinator_.setState(TxState.COMMITTING);
/* 306:    */       }
/* 307:    */       catch (RuntimeException error)
/* 308:    */       {
/* 309:583 */         String msg = "Error in committing: " + error.getMessage() + " - rolling back instead";
/* 310:584 */         Configuration.logWarning(msg, error);
/* 311:    */         try
/* 312:    */         {
/* 313:586 */           rollback(getCoordinator().isRecoverableWhileActive().booleanValue(), false);
/* 314:587 */           throw new RollbackException(msg);
/* 315:    */         }
/* 316:    */         catch (HeurCommitException e)
/* 317:    */         {
/* 318:589 */           Configuration.logWarning("Illegal heuristic commit during rollback:" + e);
/* 319:590 */           throw new HeurMixedException(e.getHeuristicMessages());
/* 320:    */         }
/* 321:    */       }
/* 322:596 */       Enumeration enumm = participants.elements();
/* 323:597 */       while (enumm.hasMoreElements())
/* 324:    */       {
/* 325:598 */         Participant p = (Participant)enumm.nextElement();
/* 326:599 */         if (!this.readOnlyTable_.containsKey(p))
/* 327:    */         {
/* 328:600 */           CommitMessage cm = new CommitMessage(p, commitresult, onePhase);
/* 329:607 */           if ((onePhase) && (this.cascadeList_ != null))
/* 330:    */           {
/* 331:609 */             Integer sibnum = (Integer)this.cascadeList_.get(p);
/* 332:610 */             if (sibnum != null) {
/* 333:611 */               p.setGlobalSiblingCount(sibnum.intValue());
/* 334:    */             }
/* 335:612 */             p.setCascadeList(this.cascadeList_);
/* 336:    */           }
/* 337:614 */           this.propagator_.submitPropagationMessage(cm);
/* 338:    */         }
/* 339:    */       }
/* 340:619 */       commitresult.waitForReplies();
/* 341:620 */       int res = commitresult.getResult();
/* 342:622 */       if (res != 0)
/* 343:    */       {
/* 344:624 */         if (res == 2)
/* 345:    */         {
/* 346:625 */           Hashtable hazards = commitresult.getPossiblyIndoubts();
/* 347:626 */           Hashtable heuristics = commitresult.getHeuristicParticipants();
/* 348:    */           
/* 349:628 */           addToHeuristicMap(heuristics);
/* 350:629 */           enumm = participants.elements();
/* 351:630 */           while (enumm.hasMoreElements())
/* 352:    */           {
/* 353:631 */             Participant p = (Participant)enumm.nextElement();
/* 354:632 */             if (!heuristics.containsKey(p)) {
/* 355:633 */               addToHeuristicMap(p, TxState.TERMINATED);
/* 356:    */             }
/* 357:    */           }
/* 358:635 */           nextStateHandler = new HeurMixedStateHandler(this, hazards);
/* 359:    */           
/* 360:    */ 
/* 361:638 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 362:639 */           throw new HeurMixedException(getHeuristicMessages());
/* 363:    */         }
/* 364:642 */         if (res == 6)
/* 365:    */         {
/* 366:644 */           nextStateHandler = new TerminatedStateHandler(this);
/* 367:645 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 368:646 */           throw new RollbackException("Rolled back already.");
/* 369:    */         }
/* 370:647 */         if (res == 3)
/* 371:    */         {
/* 372:648 */           nextStateHandler = new HeurAbortedStateHandler(this);
/* 373:649 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 374:    */           
/* 375:    */ 
/* 376:    */ 
/* 377:    */ 
/* 378:    */ 
/* 379:655 */           throw new HeurRollbackException(getHeuristicMessages());
/* 380:    */         }
/* 381:659 */         if (res == 1)
/* 382:    */         {
/* 383:660 */           Hashtable hazards = commitresult.getPossiblyIndoubts();
/* 384:661 */           Hashtable heuristics = commitresult.getHeuristicParticipants();
/* 385:    */           
/* 386:663 */           addToHeuristicMap(heuristics);
/* 387:664 */           enumm = participants.elements();
/* 388:665 */           while (enumm.hasMoreElements())
/* 389:    */           {
/* 390:666 */             Participant p = (Participant)enumm.nextElement();
/* 391:667 */             if (!heuristics.containsKey(p)) {
/* 392:668 */               addToHeuristicMap(p, TxState.TERMINATED);
/* 393:    */             }
/* 394:    */           }
/* 395:670 */           nextStateHandler = new HeurHazardStateHandler(this, hazards);
/* 396:    */           
/* 397:672 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 398:673 */           throw new HeurHazardException(getHeuristicMessages());
/* 399:    */         }
/* 400:    */       }
/* 401:    */       else
/* 402:    */       {
/* 403:678 */         if (heuristic) {
/* 404:679 */           nextStateHandler = new HeurCommittedStateHandler(this);
/* 405:    */         } else {
/* 406:685 */           nextStateHandler = new TerminatedStateHandler(this);
/* 407:    */         }
/* 408:687 */         this.coordinator_.setStateHandler(nextStateHandler);
/* 409:    */       }
/* 410:    */     }
/* 411:    */     catch (RuntimeException runerr)
/* 412:    */     {
/* 413:690 */       errors.push(runerr);
/* 414:691 */       throw new SysException("Error in commit: " + runerr.getMessage(), errors);
/* 415:    */     }
/* 416:    */     catch (InterruptedException intr)
/* 417:    */     {
/* 418:697 */       InterruptedExceptionHelper.handleInterruptedException(intr);
/* 419:698 */       errors.push(intr);
/* 420:699 */       throw new SysException("Error in commit" + intr.getMessage(), errors);
/* 421:    */     }
/* 422:703 */     return getHeuristicMessages();
/* 423:    */   }
/* 424:    */   
/* 425:    */   protected HeuristicMessage[] rollback(boolean indoubt, boolean heuristic)
/* 426:    */     throws HeurCommitException, HeurMixedException, SysException, HeurHazardException, IllegalStateException
/* 427:    */   {
/* 428:723 */     Stack errors = new Stack();
/* 429:724 */     CoordinatorStateHandler nextStateHandler = null;
/* 430:    */     try
/* 431:    */     {
/* 432:727 */       this.coordinator_.setState(TxState.ABORTING);
/* 433:    */       
/* 434:    */ 
/* 435:    */ 
/* 436:731 */       this.committed_ = new Boolean(false);
/* 437:    */       
/* 438:733 */       Vector participants = this.coordinator_.getParticipants();
/* 439:734 */       int count = participants.size() - this.readOnlyTable_.size();
/* 440:    */       
/* 441:736 */       TerminationResult rollbackresult = new TerminationResult(count);
/* 442:    */       
/* 443:    */ 
/* 444:    */ 
/* 445:740 */       Enumeration enumm = participants.elements();
/* 446:741 */       while (enumm.hasMoreElements())
/* 447:    */       {
/* 448:742 */         Participant p = (Participant)enumm.nextElement();
/* 449:743 */         if (!this.readOnlyTable_.containsKey(p))
/* 450:    */         {
/* 451:744 */           RollbackMessage rm = new RollbackMessage(p, rollbackresult, indoubt);
/* 452:    */           
/* 453:746 */           this.propagator_.submitPropagationMessage(rm);
/* 454:    */         }
/* 455:    */       }
/* 456:751 */       rollbackresult.waitForReplies();
/* 457:752 */       int res = rollbackresult.getResult();
/* 458:757 */       if ((indoubt) && (res != 0))
/* 459:    */       {
/* 460:759 */         if (res == 2)
/* 461:    */         {
/* 462:760 */           Hashtable hazards = rollbackresult.getPossiblyIndoubts();
/* 463:761 */           Hashtable heuristics = rollbackresult.getHeuristicParticipants();
/* 464:    */           
/* 465:763 */           addToHeuristicMap(heuristics);
/* 466:764 */           enumm = participants.elements();
/* 467:765 */           while (enumm.hasMoreElements())
/* 468:    */           {
/* 469:766 */             Participant p = (Participant)enumm.nextElement();
/* 470:767 */             if (!heuristics.containsKey(p)) {
/* 471:768 */               addToHeuristicMap(p, TxState.TERMINATED);
/* 472:    */             }
/* 473:    */           }
/* 474:770 */           nextStateHandler = new HeurMixedStateHandler(this, hazards);
/* 475:    */           
/* 476:772 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 477:773 */           throw new HeurMixedException(getHeuristicMessages());
/* 478:    */         }
/* 479:776 */         if (res == 4)
/* 480:    */         {
/* 481:777 */           nextStateHandler = new HeurCommittedStateHandler(this);
/* 482:778 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 483:    */           
/* 484:    */ 
/* 485:    */ 
/* 486:782 */           throw new HeurCommitException(getHeuristicMessages());
/* 487:    */         }
/* 488:786 */         if (res == 1)
/* 489:    */         {
/* 490:787 */           Hashtable hazards = rollbackresult.getPossiblyIndoubts();
/* 491:788 */           Hashtable heuristics = rollbackresult.getHeuristicParticipants();
/* 492:    */           
/* 493:    */ 
/* 494:791 */           addToHeuristicMap(heuristics);
/* 495:792 */           enumm = participants.elements();
/* 496:793 */           while (enumm.hasMoreElements())
/* 497:    */           {
/* 498:794 */             Participant p = (Participant)enumm.nextElement();
/* 499:795 */             if (!heuristics.containsKey(p)) {
/* 500:796 */               addToHeuristicMap(p, TxState.TERMINATED);
/* 501:    */             }
/* 502:    */           }
/* 503:799 */           nextStateHandler = new HeurHazardStateHandler(this, hazards);
/* 504:    */           
/* 505:801 */           this.coordinator_.setStateHandler(nextStateHandler);
/* 506:802 */           throw new HeurHazardException(getHeuristicMessages());
/* 507:    */         }
/* 508:    */       }
/* 509:    */       else
/* 510:    */       {
/* 511:808 */         if (heuristic) {
/* 512:809 */           nextStateHandler = new HeurAbortedStateHandler(this);
/* 513:    */         } else {
/* 514:814 */           nextStateHandler = new TerminatedStateHandler(this);
/* 515:    */         }
/* 516:816 */         this.coordinator_.setStateHandler(nextStateHandler);
/* 517:    */       }
/* 518:    */     }
/* 519:    */     catch (RuntimeException runerr)
/* 520:    */     {
/* 521:821 */       runerr = 
/* 522:    */       
/* 523:    */ 
/* 524:    */ 
/* 525:    */ 
/* 526:    */ 
/* 527:    */ 
/* 528:    */ 
/* 529:    */ 
/* 530:    */ 
/* 531:    */ 
/* 532:    */ 
/* 533:    */ 
/* 534:    */ 
/* 535:    */ 
/* 536:836 */         runerr;errors.push(runerr);throw new SysException("Error in rollback: " + runerr.getMessage(), errors);
/* 537:    */     }
/* 538:    */     catch (InterruptedException e)
/* 539:    */     {
/* 540:827 */       e = e;
/* 541:    */       
/* 542:829 */       InterruptedExceptionHelper.handleInterruptedException(e);
/* 543:830 */       errors.push(e);
/* 544:831 */       throw new SysException("Error in rollback: " + e.getMessage(), errors);
/* 545:    */     }
/* 546:    */     finally {}
/* 547:838 */     return getHeuristicMessages();
/* 548:    */   }
/* 549:    */   
/* 550:    */   protected void forget()
/* 551:    */   {
/* 552:855 */     CoordinatorStateHandler nextStateHandler = null;
/* 553:    */     
/* 554:857 */     Vector participants = this.coordinator_.getParticipants();
/* 555:    */     
/* 556:859 */     int count = participants.size() - this.readOnlyTable_.size();
/* 557:860 */     Enumeration enumm = participants.elements();
/* 558:861 */     ForgetResult result = new ForgetResult(count);
/* 559:862 */     while (enumm.hasMoreElements())
/* 560:    */     {
/* 561:863 */       Participant p = (Participant)enumm.nextElement();
/* 562:864 */       if (!this.readOnlyTable_.containsKey(p))
/* 563:    */       {
/* 564:865 */         ForgetMessage fm = new ForgetMessage(p, result);
/* 565:866 */         this.propagator_.submitPropagationMessage(fm);
/* 566:    */       }
/* 567:    */     }
/* 568:    */     try
/* 569:    */     {
/* 570:874 */       result.waitForReplies();
/* 571:    */     }
/* 572:    */     catch (InterruptedException inter)
/* 573:    */     {
/* 574:879 */       InterruptedExceptionHelper.handleInterruptedException(inter);
/* 575:    */     }
/* 576:882 */     nextStateHandler = new TerminatedStateHandler(this);
/* 577:883 */     this.coordinator_.setStateHandler(nextStateHandler);
/* 578:    */   }
/* 579:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions\3.7.0\transactions-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.imp.CoordinatorStateHandler
 * JD-Core Version:    0.7.0.1
 */